function [adists, assignments, bassigned] = AssignDists(dists)

maxval = 10000;
    
sz = size(dists);
nobjs = sz(1);

adists = zeros(nobjs, 1);

assignments = zeros(nobjs, 1);


for i = 1:nobjs
    
     
    dmin = maxval;
    
    for j = 1:nobjs
       [d, index] = min(dists(j,:));
            
        if d < dmin
           dmin = d;
           jassign = j;
           iassign = index;        
        end
    end        

    
    if dmin < maxval
       adists(jassign) = dmin;
       assignments(jassign) = iassign;
       dists(:,iassign) = maxval;
       dists(jassign,:) = maxval;
    
    end                                
end 

bassigned = 1;

